package com.music.service.impl;

import com.music.dao.SongListTypeMapper;
import com.music.entity.SongListType;
import com.music.service.SongListTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SongListTypeServiceImpl implements SongListTypeService {

    @Autowired
    private SongListTypeMapper songListTypeMapper;

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public List<SongListType> getRootSongListType() {
        /*List rootSongListType = redisTemplate.opsForList().range("rootSongListType",0,-1);
        return rootSongListType;*/
        List<SongListType> rootSongListTypeList = songListTypeMapper.findByCondition(null);
        return rootSongListTypeList;
    }

    @Override
    public List<SongListType> getSubSongListTypeByParentTypeId(Integer parentTypeId) {
        /*List<SongListType> subSongListTypeList = (List<SongListType>)redisTemplate.opsForHash().get("subSongListType",String.valueOf(parentTypeId));
        return subSongListTypeList;*/
        List<SongListType> subSongListTypeList = songListTypeMapper.findByCondition(parentTypeId);
        return subSongListTypeList;
    }
}
